<!-- 费用审核列表 -->
<template>
  <div class="examine-detail">
    <!-- 顶部标题栏组件 -->
    <top-header :leftArrow="leftArrow"></top-header>
    <!-- 中心内容 -->
    <van-cell-group>
      <van-cell
        v-for="(item, index) in formList"
        :key="index"
        @click="toDetail(item)">
        <template #title>
          <div class="van-title">
            <div class="van-top">
              <van-tag plain type="primary" color="burlywood">{{ index + 1 }}</van-tag>
              <span class="custom-title">{{ item.date | filterTime }}</span>
              <van-tag type="primary" color="burlywood">￥{{ item.costTotal }}</van-tag>
            </div>
            <span class="cust-title">{{ item.cust_name }}</span>
          </div>
        </template>
        <template #label>
          <van-tag plain type="primary" color="burlywood">{{ item.deliverMan }}</van-tag>
          <span class="custom-title">{{ item.request }}</span>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
import { TopHeader } from '@/components'
import { getApprovalForm } from '@/request/api'
export default {
  name: 'ExamineDetail',
  components: {
    TopHeader
  },
  filters: {
    filterTime (val) {
      return val.slice(0, 10)
    }
  },
  data () {
    return {
      leftArrow: true, // 顶部标题栏组件是否有返回按钮
      formList: []
    }
  },
  created () {
    this.getFormList()
  },
  methods: {
    // 获取费用详情数据
    getFormList () {
      const param = {
        approvalFormId: sessionStorage.getItem('approvalFormId')
      }
      getApprovalForm(param).then(res => {
        if (res.Tag === 1) {
          this.formList = res.Data
        }
      })
    },
    // 点击事件,跳转页面到详情costDetail
    toDetail (value) {
      this.$router.push({
        name: 'CostDetail',
        params: value
      })
    }
  }
}
</script>

<style scoped lang="less">
.examine-detail {
  width: 100%;
  height: 100%;
  .van-cell-group {
    height: calc(100% - 1.2rem);
    background: inherit;
    overflow: auto;
    .van-cell {
      .van-cell__title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        .van-title {
          display: flex;
          .van-top {
            flex: 1;
            display: flex;
            align-items: center;
            .van-tag {
              margin-left: 2px;
            }
          }
          .cust-title {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            text-align: right;
          }
        }
        .van-tag {
          margin-right: 2px;
        }
        .van-cell__label {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
}
</style>
